package com.hotel.web.controller.hotel;

import com.hotel.common.annotation.Log;
import com.hotel.common.core.controller.BaseController;
import com.hotel.common.core.domain.AjaxResult;
import com.hotel.common.core.page.TableDataInfo;
import com.hotel.common.enums.BusinessType;
import com.hotel.common.utils.poi.ExcelUtil;
import com.hotel.system.domain.hotel.Expenses;
import com.hotel.system.domain.hotel.HotelInventory;
import com.hotel.system.domain.hotel.HotelInventoryLog;
import com.hotel.system.service.ExpensesService;
import com.hotel.system.service.ISysKcglService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 岗位信息操作处理
 * 
 * @author hotel
 */
@Controller
@RequestMapping("/hotel/expenses")
public class ExpensesController extends BaseController
{
    private String prefix = "hotel/expenses";

    @Autowired
    private ExpensesService expensesService;

    @RequiresPermissions("system:kcgl:view")
    @GetMapping()
    public String operlog()
    {
        return prefix + "/post";
    }

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Expenses expenses) {

        startPage();
        List<Expenses> list = expensesService.selectExpensesList(expenses);
        return getDataTable(list);
    }

    @RequiresPermissions("hotel:expenses:addExpenses")
    @GetMapping("/addExpenses")
    public String addExpenses()
    {
        return prefix + "/add";
    }

    @RequiresPermissions("hotel:expenses:addSave")
    @PostMapping("/addSave")
    @ResponseBody
    public AjaxResult addSave(@Validated Expenses expenses)
    {

        return toAjax( expensesService.insertExpenses(expenses));
    }

    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        mmap.put("post", expensesService.selectExpensesId(id));
        return prefix + "/edit";
    }

    /**
     * 出库入库调整
     */
    @PostMapping("/editExpenses")
    @ResponseBody
    public AjaxResult editExpenses(@Validated Expenses expenses)
    {
        return toAjax(expensesService.updateExpenses(expenses));
    }


}
